package com.bosssoft.hr.train.mybatis.service;

import com.bosssoft.hr.train.mybatis.demo.User;
import com.bosssoft.hr.train.mybatis.mapper.UserMapper;
import com.bosssoft.hr.train.mybatis.util.MyBatisUtil;

import java.util.List;

/**
 * @Author: wang
 * @Time: 2022/3/10
 */
public class UserServiceImpl implements UserService{

UserMapper mapper= MyBatisUtil.getSession().getMapper(UserMapper.class);

    public boolean save(User user) {
        if (mapper.add(user)<=0){
            return false;
        }else
        return true ;
    }

    public boolean remove(User user) {
        if (mapper.delete(user)<=0){
            return false;
        }else
        return true;
    }

    public boolean update(User user) {
        if (mapper.update(user)<=0){
            return false;
        }else
        return true;
    }

    public List<User> findByName(String name) {

        return mapper.select(name);
    }
}
